Skip to content

Adaptive soundtrack: urgent drums, crystal shimmer, flawless fanfare - #9

Merged
cmalpass merged 1 commit into
mainfrom
cmalpass-potential-enigma
Aug 27, 2026
Merged

Adaptive soundtrack: urgent drums, crystal shimmer, flawless fanfare#9
cmalpass merged 1 commit into
mainfrom
cmalpass-potential-enigma

Conversation

@cmalpass

Copy link
Copy Markdown
Owner

Music now reacts to the run:

  • Urgent drum layer (per-theme kick/hat patterns) crossfades in when hearts ≤ 2, a hazard looms within 420px ahead, or the Magma King is in the arena.
  • Shimmer pad layer (lead +12 semitones, sparkle overtones) sparkles over crystal-dense stretches (4+ uncollected within 280px).
  • Layers are always scheduled while music plays — only gains move — so transitions are click-free, and stopping music / victory fades them out.
  • Flawless-run fanfare: a brighter 8-note arpeggio + bell shimmer plays when the victory comes with zero damage; plain run keeps the original fanfare.
  • Pure trigger logic in new src/adaptive.ts (adaptiveFlags), wired through a new GameCtx.onPlayerHit hook and a hits counter in the game.

Validated locally (CI is failing for pre-existing unrelated reasons, so local validation is the gate):

  • npm run typecheck
  • npm test — 209/209 (was 193; +9 pure adaptive tests, +7 game-level tests) ✓
  • npm run build — 131.67 kB / 40.43 kB gzip ✓
  • npm run lint
  • Headless Playwright E2E: audio unlocks, theme music starts, urgent gain crossfades to 0.885, shimmer to 0.839, urgent settles to 0.015, flawless victory routes {flawless: true}, post-hit victory routes {flawless: false}, zero page errors ✓

Screenshots: /tmp/tinyrex-e2e/01-urgent.png, 02-shimmer.png, 03-victory.png

Music now reacts to the run:
- Urgent drum layer (kick/hat patterns per theme) crossfades in when
  hearts drop to 2 or fewer, a hazard looms within 420px ahead, or the
  Magma King is in the arena.
- Shimmer pad layer (lead +12 semitones with sparkle overtones) sparkles
  over crystal-dense stretches (4+ uncollected within 280px).
- Layers are always scheduled; only gains move, so transitions are
  click-free and stop/victory fade them out.
- Victory fanfare gets a brighter "flawless run" variant (8-note arpeggio
  + bell shimmer) when the run took no damage; the game tracks hits via
  a new GameCtx.onPlayerHit hook.
- Pure trigger logic lives in src/adaptive.ts (adaptiveFlags) with 9 unit
  tests; 7 more game-level tests cover hit tracking and fanfare routing.

Validated: typecheck, 209/209 tests, build (131.67 kB / 40.43 kB gzip),
lint, and headless E2E (gain crossfades measured live, zero page errors).
@cmalpass
cmalpass merged commit 7231e6f into main Aug 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant